<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp_lib/init.jsp"%>

<script type="text/javascript">
	var add_form_panel = Ext.create("Ext.form.Panel", {
		url : "add.htm",
		buttonAlign : "center",
		bodyStyle : "padding: 10px;overflow:scroll;",
		defaultType : "textfield",
		width : 1000,
		height:650,
		items : [ {
			fieldLabel : "标题",
			name : "art.title",
			xtype : "textfield",
			anchor : '80%',
			allowBlank : false
		},{
			name : "art.cate",
			xtype : "textfield",
			value:'${cate}',
			hidden : true
		},{
			xtype : "ueditor",
			fieldLabel : "内容",
			name : "art.content",
			width : 800,
			height : 300
		}],
		buttons : [ {
			text : "保存",
			formBind : true, //only enabled once the form is valid
			disabled : true,
			handler : function() {
				var form = this.up("form").getForm();
				if (form.isValid()) {
					form.submit({
						waitMsg : "保存中...",
						success : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
							add_form_panel_win.close();
							dataStore.load();
						},
						failure : function(form, action) {
							Ext.Msg.alert("提示", action.result.tip.msg);
						}
					});
				}
			}
		} ]
	});

	var add_form_panel_win = Ext.create("Ext.Window", {
		title : "文章添加",
		closeAction : "hide",
		items : add_form_panel
	});

	function myAdd() {
		add_form_panel.getForm().reset();
		add_form_panel_win.show();
	}
</script>
